<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <link rel="icon" href="favicon.ico" />
    <title>Html - 实验室</title>
    <style>
      html,
      body {
        border: 0;
        padding: 0;
        margin: 0;
        height: 100%;
        overflow: hidden;
      }
    </style>
  </head>
  <body>
    <div>Html 实验室</div>
  </body>
  <script>
    // const nowDate = new Date();
    // const nowTime = new Date().getTime();
    // const oneDay = 24 * 60 * 60 * 1000;

    // console.log(nowTime);
    // console.log([nowTime - oneDay, nowTime]);
    // console.log([nowTime - oneDay * 7, nowTime]);
    // console.log(new Date("yyyy/MM/dd hh:mm:ss"));
    // var date = new Date(strtime.replace(/-/g, '/'));
    
    // console.log(date);
    // // ===========================
    // // date、dateTime、time、string;
    // function dateToString(date) {
    //     date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
    // }

    function latelyDate(n){
        const date = new Date();
        let res = [0, 0]
        res[1] = date.getFullYear() + '-' +
        ((date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)) + '-' + date.getDate()

        date.setDate(date.getDate() - n)
        res[0] = date.getFullYear() + '-' +
        ((date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)) + '-' + date.getDate()
        return res
    }
    function thisYear(){
        const date = new Date();
        let res = [0, 0]
        res[0] = date.getFullYear() + '-01-01'
        res[1] = date.getFullYear() + '-12-31'
        return res
    }
    console.log(latelyDate(30));
  </script>
</html>
